import request from '@/utils/request'

// 门店列表接口返回类型
export interface ItemApplyResponse {
  code: number
  message: string
  rows: Store[]
}

// 获取用户手机号返回类型
export interface UserPhoneResponse {
  code: number
  message: string
  data: {
    phoneNumber: string
    token: string
  }
}

// 搜索参数类型
export interface SearchParams {
    shopName?: string
}

// 门店数据类型
export interface Store {
  id: number
  shopName: string
  address: string
  phone: string
  status: string
  hours: string
  latitude: number
  longitude: number
}

// 获取门店列表
export function getStoreList(params?: SearchParams) {
  return request<ItemApplyResponse>({
    url: '/basics/shopInfo/list',
    method: 'GET',
    data: params
  })
} 

// 获取用户手机号
export function getUserPhone({code,openid}:{code:string,openid:string}) {
  return request<UserPhoneResponse>({
    url: '/getvxPhoneNumber',
    method: 'GET',
    data: { code,openid }
  })
}

// 项目列表返回类型
export interface ProjectListResponse {
  code: number
  message: string
  rows: Project[]
}

// 项目数据类型
export interface Project {
  id: number
  itemName: string
  itemPrice: number
}

// 项目列表
export function getProjectList() {
  return request<ProjectListResponse>({
    url: '/shop/item/list',
    method: 'GET'
  })
}

// 查询美导
export function getBeautician() {
  return request<ProjectListResponse>({
    url: '/system/user/list',
    method: 'GET',
    data: {userType:"02"}
  })
}

// 预约参数类型
export interface AppointmentParams {
  applyUserId: number;
  applyTime: string;
  applyConsultant: number;
  itemId: number;
  shopId: number;
  status: string;
}

// 预约返回类型
export interface AppointmentResponse {
  code: number;
  message: string;
  rows: any;
}

// 提交预约
export function submitAppointment(data: AppointmentParams) {
  return request<AppointmentResponse>({
    url: '/basics/itemApply',
    method: 'POST',
    data
  });
}

// 我的预约
export function getMyAppointment() {
  return request<AppointmentResponse>({
    url: '/basics/itemApply/list',
    method: 'GET',
  });
}

// 取消预约参数
export interface CancelAppointmentParams {
  id: number;
  status: string;
}

// 取消预约
export function cancelAppointment(data: CancelAppointmentParams) {
  return request<AppointmentResponse>({
    url: '/basics/itemApply',
    method: 'PUT',
    data
  });
}